<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>宜鲜生</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!-- load css -->
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css?v=v3.3.7" media="all">
    <link rel="stylesheet" type="text/css" href="../css/font/iconfont.css?v=1.0.0" media="all">
    <link rel="stylesheet" type="text/css" href="../css/layui.css?v=1.0.9" media="all">
    <link rel="stylesheet" type="text/css" href="../css/main.css?v1.3.4" media="all">

    <link rel="stylesheet" type="text/css" href="../css/autocomplete.css" media="all">
    <style>
        .add-subcat .layui-input-inline {
            width: 350px;
        }
    </style>
</head>
<body>
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <!--头部搜索-->
                <section class="panel panel-padding">
                    <form class="layui-form" action="/education/admin/property">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <select name="_query.areaid" lay-filter="area">
                                    <option value="">区县</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="_query.streetid">
                                    <option value="">街道办</option>
                                </select>
                            </div>

                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input class="layui-input" name="_query.keyword" placeholder="关键字">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button lay-submit class="layui-btn" lay-filter="search">查找</button>
                            </div>
                        </div>
                    </form>
                </section>

                <!--列表-->
                <section class="panel panel-padding">

                    <div class="group-button">
                        <button class="layui-btn layui-btn-small modal-catch"
                                data-params='{"content":".add-subcat", "title":"添加","type":"1", "full":"true", "data":"url=/education/admin/property/save"}'>
                            <i class="iconfont">&#xe649;</i> 添加
                        </button>
                        <button class="layui-btn layui-btn-small modal-catch" data-name="propertyData"
                                data-params='{"content": ".add-subcat","full":"true","title":"编辑","key":"ids=","data":"url=/education/admin/property/update","type":"1"}'>
                            <i class="iconfont">&#xe653;</i>编辑
                        </button>
                        <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "/education/admin/property/delete"}'>
                            <i class="iconfont">&#xe626;</i> 删除
                        </button>

                        <button class="layui-btn layui-btn-small layui-btn-normal" id="importBtn"
                                data-url="/education/admin/import/property">
                            <i class="layui-icon">&#xe608;</i>导入
                        </button>
                        <button class="layui-btn layui-btn-small layui-btn-normal" id="exportBtn"
                                data-url="/education/admin/export?type=property">
                            <i class="iconfont">&#xe60a;</i>导出
                        </button>
                        <div style="display: none">
                            <input type="file" name="file" class="layui-upload-file" id="importFile">
                        </div>
                    </div>
                    <div id="list" class="layui-form"></div>

                    <div class="text-right" id="page"></div>
                </section>
            </div>
        </div>
    </div>
    <div class="add-subcat">
        <form class="layui-form layui-form-pane" action="/education/admin/property/save">
            <input type="hidden" id="inspectuserid" name="inspectuserid">
            <input type="hidden" name="departmentid"/>
            <div class="layui-form-item">
                <label class="layui-form-label">所属街道</label>
                <div class="layui-input-block">
                    <input type="text" name="parentname"
                           onclick="javascript:choice();" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">综合体名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required jq-verify="required" jq-error="请输入名称" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="address" required jq-verify="required" jq-error="请输入地址" class="layui-input"
                            id="address">
                </div>
                <a class="layui-btn" onclick="beforeChoice();">
                    <i class="iconfont">&#xe649;</i> 选择
                </a>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">巡查员</label>
                <div class="layui-input-block">
                    <input type="text" name="inspector" placeholder="请输入手机号或用户姓名进行查找..."
                          id="autocompleteInput" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="number" name="ord" required jq-verify="number" jq-error="排序必须为数字" value="0"
                           class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea name="description" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <!--<div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="status" title="启用" value="1" checked />
                    <input type="radio" name="status" title="禁用" value="0" />
                </div>
            </div>-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit" before-fun="beforeSubmit();">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>


</body>
<!--#include file="property-list.html"-->
<script src="../js/layui/layui.js"></script>
<!--#include file="common/version.html"-->
<script type="text/javascript" src="../js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/lib/bootstrap.autocomplete.js"></script>
<script>
    layui.extend({ //设定模块别名
        area_select:'../module/js/area_select'
    });

    layui.define(['user_list', 'area_select', 'import_export'], function(exports){
        var $ = layui.jquery;
        // Initialize ajax autocomplete:
        $('#autocompleteInput').autocomplete({
            source:function(query,process){
                var matchCount = this.options.items;//返回结果集最大数量
                $.post("/education/api/user",{"_query.keyword":query, "_query.roleid":"AssociateInspector"},function(respData){
                    console.log(respData);
                    if(respData.code == 200) {
                        return process(respData.data);
                    }
                });
            },
            formatItem:function(item){
                var mobile = item["mobile"] || '';
                var name = item["nickname"] || '';
                var username = item["username"] || '';
//                return username +"("+ name +"，"+ mobile +") - "+ level;
                return name +"("+ username + ")";
            },
            setValue:function(item){
//                $('#inspectuserid').val(item["ids"]);
                return {'data-value':item["nickname"],'real-value':item["ids"]};
            }
        });
    });

    function beforeSubmit(){
        $('#inspectuserid').val($('#autocompleteInput').attr('real-value'));
    }

    function strRepeat(str, count) {
        var ret = "";
        for (var i = 0; i < count; i++) {
            ret += str;
        }
        return ret;
    }

    function choiceDept(item){
        var $ = layui.jquery;
        $('input[name="departmentid"]').val(item.id);
        $('input[name="parentname"]').val(item.name);
    }

    function choice(){
        layer.open({
            type: 2,
            content: "dept-tree.html", "title": "选择部门", "area":["500px","480px"], "maxmin":"true"
        });
    }

    function beforeChoice(){
        layer.open({
            type: 2,
            content: "map.html",
            "title": "选择地点",
            area: ['550px', '480px'], "maxmin":"true"
        });
    }

    /*function inspector(){
        layer.open({
            type: 2,
            content: "user.html", "title": "选择巡查员", "area":"320px,580px", "maxmin":"true"
        });
    }

    function inspectored(item){
        alert('选择完成')
        var $ = layui.jquery;
        $('input[name="principaluserids"]').val(item.id);
        $('input[name="inspector"]').val(item.name);
    }*/
</script>

</html>